#ifndef __RATIONAL_H__
#define __RATIONAL_H__

#include <algorithm>
#include <cstdlib>
#include <ostream>

using std::ostream;


class Rational {
    
    int numerator;
    int denominator;
    
    void simplify();
    int GetGCD(int a, int b) const;
    void Swap(Rational& r);
    
public:
    explicit Rational(int inpNumerator = 0, int inpDenomiantor = 1);
    Rational(const Rational& r);
    ~Rational();
    
    Rational& operator= (const Rational& r); 
    Rational& operator+= (const Rational& r); 
    Rational& operator-= (const Rational& r); 
    Rational& operator*= (const Rational& r); 
    Rational& operator/= (const Rational& r); 
    Rational& operator++();
    Rational operator++(int);
    Rational& operator--();
    Rational operator--(int);
    
    operator double () const;
    
    const int& GetNumerator() const;
    const int& GetDenomiantor() const;
};

Rational operator+ (const Rational& a, const Rational& b);
Rational operator- (const Rational& a, const Rational& b);
Rational operator* (const Rational& a, const Rational& b);
Rational operator/ (const Rational& a, const Rational& b);

bool operator== (const Rational& a, const Rational& b);
bool operator!= (const Rational& a, const Rational& b);
bool operator<= (const Rational& a, const Rational& b);
bool operator>= (const Rational& a, const Rational& b);
bool operator<  (const Rational& a, const Rational& b);
bool operator>  (const Rational& a, const Rational& b);

ostream& operator<<(ostream& oout, const Rational& r);

#endif /* __RATIONAL_H__ */